package com.api.common;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by rio on 2017/1/18.
 */
public class JsonUtils {
    public static Map<String, Object> successReturn(Object object) {
        Map<String, Object> result = new HashMap<String, Object>();
        Object o;
        if (object instanceof List) {
            o = new JSONArray(object);
        } else {
            o = new JSONObject(object);
        }

        result.put("code","0000");
        result.put("desc",ResCodeMessageCache.getMessageDesc("0000"));
        result.put("model",o);
        return result;
    }

}
